home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!cader
- From: cader@netcom.com (Charles Ader)
- Subject: Re: Tough FACTORIAL math problem...
- Message-ID: <caderDn5G9L.9oM@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: TIN [version 1.2 PL1]
- References: <4fr8be$ass@news.iconn.net> <31224679.6193@born.com> <312A49F0.167E@silk.gsfc.nasa.gov>
- Date: Wed, 21 Feb 1996 23:36:57 GMT
- Sender: cader@netcom7.netcom.com
-
- I have been thinking about this problem for a few days. It
- occured to me that it may be possible to find the answer
- to the question of "What is the least significant non-zero
- digit of N!?" by using an 8 by 8 multiplier table.
-
- The input would be the stream of digits from 2 to N! but the
- digit values of 0 and 1 are elminated because they do not
- affect the result of the multiplication.
-
- Also elminate pairs of 2s and 5s.
-
- For example 12! = 479,001,600
-
- The raw input stream is: 123456789101112
- Throw out all the 1s and 0s: 234567892
- Removes pairs of 2s and 5s: 3467892
- Multiply the digit stream: 3*4*6*7*8*9*2 = 72,576
- (Only the least significant digit means anything.)
-
- Note:
- The multiply step only needs to keep the least signifcant two
- digits because all the factors of 10 have been removed from
- the input stream.
-
- This scheam seems to work for 12! and 13!
-
- I didn't see any of the messages in this thread using this
- approach.
-
-
- Charles.
-